package com.cy.security.controller;


import com.cy.security.util.JwtUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class AuthenticationController{

 @RequestMapping("/login")
 public Map<String,Object> doLogin(String username,String password){
  Map<String,Object> map=new HashMap<>();
  if("jack".equals(username)&&"123456".equals(password)){
   map.put("state","200");
   map.put("message","login ok");
   Map<String,Object> claims=new HashMap<>();
   claims.put("username",username);
   map.put("Authentication",JwtUtils.generatorToken(claims));
   return map;
  }else {
   map.put("state","500");
   map.put("message","login failure");
  return  map;
  }
 }
}
